#include "pigeon.h"

pigeon::pigeon(QWidget *parent)
    : QMainWindow(parent)
{
	ui.setupUi(this);

//création du menu
	//frame
	QFrame *frameMain = new QFrame(this);
	frameMain->setFrameShape(QFrame::StyledPanel);
	frameMain->setGeometry(5, 30, 570, 550);

	QFrame *frameMenu = new QFrame(this);
	frameMenu->setFrameShape(QFrame::StyledPanel);
	frameMenu->setGeometry(580, 30, 190, 550);

	//menu haut
	ui.menuFichier->addAction( "Quit",qApp,SLOT(quit()) );

	//page central
	QSLmain = new QStackedLayout;
	frameMain->setLayout(QSLmain);

	//page menu
	QSLmenu = new QStackedLayout;
	frameMenu->setLayout(QSLmenu);

	//création des menu principaux
	QWidget* Wmenumenu = new QWidget;
	    QPushButton *buttonNewGame = new QPushButton("Nouveau jeu");
	    QPushButton *buttonQuit = new QPushButton("Quit");

		//conection des slots
	    QObject::connect(buttonQuit, SIGNAL(clicked()), qApp, SLOT(quit()));
	    QObject::connect(buttonNewGame, SIGNAL(clicked()),this,SLOT(newgame()));

	    QVBoxLayout *vbox = new QVBoxLayout;
	    vbox->addWidget(buttonNewGame);
	    vbox->addWidget(buttonQuit);
	Wmenumenu->setLayout(vbox);

	QSLmenu->addWidget(Wmenumenu);
	QSLmenu->setCurrentWidget(Wmenumenu);


	QWidget* Wmenumain = new QWidget;
		QLabel *label = new QLabel();
		label->setPixmap(QPixmap("img/mainpigeon.png"));


	    QVBoxLayout *vbox2 = new QVBoxLayout;
	    vbox2->addWidget(label);

	Wmenumain->setLayout(vbox2);

	QSLmain->addWidget(Wmenumain);
	QSLmain->setCurrentWidget(Wmenumain);




}

pigeon::~pigeon()
{

}

void pigeon::newgame(){
	std::cout<<"Button newgame pressed"<<std::endl;
	Game* Pgame =new Game;
	QWidget* Wmenupregame=Pgame->WNbPlayer();

		QSLmain->addWidget(Wmenupregame);
		QSLmain->setCurrentWidget(Wmenupregame);
}


void pigeon::playername(int nbplayer){
	std::cout<<nbplayer<<std::endl;
}
